﻿using System;
using System.Linq;
using WebExam.DataEntities;

namespace WebExam.DataProvider
{
    public interface IExamPaperRepository
    {

        /// <summary>
        /// 获取试卷信息
        /// </summary>
        /// <param name="start">开始位置</param>
        /// <param name="takeSize">获取条数</param>
        IQueryable<ExamPaper> GetAll(int start, int takeSize);

        /// <summary>
        /// 获取指定科目下的试卷信息
        /// </summary>
        /// <param name="kmId">科目Id</param>
        /// <param name="start">开始位置</param>
        /// <param name="takeSize">获取条数</param>
        IQueryable<ExamPaper> GetAll(int kmId, int start, int takeSize);

        /// <summary>
        /// 获取单个试卷信息
        /// </summary>
        /// <param name="examId">试卷Id</param>
        ExamPaper Get(int examId);

        /// <summary>
        /// 添加试卷信息
        /// </summary>
        /// <param name="obj">试卷对象</param>
        ExamPaper Add(ExamPaper obj);

        /// <summary>
        /// 更新试卷信息
        /// </summary>
        /// <param name="examId">试卷Id</param>
        /// <param name="update">包含更新操作的方法</param>
        ExamPaper Update(int examId, Action<ExamPaper> update);

        /// <summary>
        /// 删除试卷信息
        /// </summary>
        /// <param name="examId">试卷Id</param>
        bool Delete(int examId);

        /// <summary>
        /// 是否与指定科目下的试卷同名
        /// </summary>
        /// <param name="kmId">科目Id</param>
        /// <param name="paperName">试卷名称</param>
        bool IsExists(int kmId, string paperName);

        /// <summary>
        /// 统计记录条数
        /// </summary>
        int Count();

        /// <summary>
        /// 根据科目Id统计试卷条数
        /// </summary>
        /// <param name="kmId">科目Id</param>
        int Count(int kmId);

    }
}